package com.luke.source;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

public class InBoundHandlerB extends ChannelInboundHandlerAdapter {

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        System.out.println("InBoundHandlerB：" + msg);
        //ctx.fireChannelRead(msg); //从当前节点开始往下传
        throw new RuntimeException("业务异常"); //测试异常传播
    }

    /*@Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        ctx.channel().pipeline().fireChannelRead("hello world");//从Head节点开始往下传
    }*/

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        System.out.println("InBoundHandlerB#exceptionCaught");
        ctx.fireExceptionCaught(cause);
    }

}
